/**
 * 将皮肤id解析为英雄id
 * @param skinId
 * @returns {string}
 */
export function parseSkinIdToChampion(skinId){
    const str= skinId.toString();//后三位 为皮肤序号
    return  str.substring(0,str.length-3);
}

/**
 * 将皮肤id转换为path
 * @param skinId
 * @returns {Promise<void>}
 */
export  function paseSkinIdToSkinInfo(skinId){
    return  new Promise((resolve, reject) => {
        const championId = parseSkinIdToChampion(skinId);
        window.api.baseData.champion_detail( championId)
            .then(championdetail=>{
                resolve( skinToMap(championdetail.data?.skins).get(skinId)||{})
            })
    })
}


function skinToMap(skinList=[]){
    const skinMap = new Map();

    skinList.forEach(skin => {
        skinMap.set(skin.id, skin);
    })
    return skinMap;

}
